package b_threadAPI;

public class ThreadDemo3 {
    public static void main(String[] args) {
        Runnable r = new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    //获取当先线程
                    Thread t = Thread.currentThread();
                    //获取当前线程名称
                    String name = t.getName();
                    System.out.println("当前线程名字:" + name + ": " +i);
                }
            }
        };

        //创建线程对象
        Thread t1 = new Thread(r, "小明");
        Thread t2 = new Thread(r, "小红");

        t1.setPriority(10);
        int gt1 = t1.getPriority();
        int gt2 = t2.getPriority();
        System.out.println(gt1);
        System.out.println(gt2);

        t1.start();
        t2.start();
    }
}
